using System.Collections;
using System.Collections.Generic;
using PureMVC.Patterns.Mediator;
using UnityEngine;
using UnityEngine.UI;

public class HpBtnMediator : Mediator
{
    private Button _randomBtn;
    private Button _resetBtn;

    public HpBtnMediator(string mediatorName, object viewComponent = null) : base(mediatorName, viewComponent)
    {
        var root = ((GameObject)viewComponent).transform;
        var randomBtnTf = root.Find("hpButton");
        if (randomBtnTf != null)
        {
            _randomBtn = randomBtnTf.GetComponent<Button>();
            _randomBtn.onClick.AddListener(OnRandomBtnClick);
        }
        var resetBtnTf = root.Find("hpResetButton");
        if (resetBtnTf != null)
        {
            _resetBtn = resetBtnTf.GetComponent<Button>();
            _resetBtn.onClick.AddListener(OnResetBtnClick);
        }
    }
    
    private void OnRandomBtnClick()
    {
        ApplicationFacade.Instance.SendNotification(Notifications.RandomBtnClick);
    }
    
    private void OnResetBtnClick()
    {
        ApplicationFacade.Instance.SendNotification(Notifications.ResetBtnClick);
    }
}
